﻿using NUnit.Framework;
using Sasa.QualityTools.CodeAnalysis.Core.Models;
using System;
using System.IO;

namespace Sasa.QualityTools.CodeAnalysis.Core.Tests.Unit.Models
{
    [TestFixture]
    public class RuleSetConverterTest
    {
        private static readonly string BundleDir = Path.Combine(Environment.GetEnvironmentVariable("VS100COMNTOOLS"), "..", "..", "Team Tools", "Static Analysis Tools", "Rule Sets");

        private RuleSetConverter testee;


        [SetUp]
        public void SetUp()
        {
            testee = new RuleSetConverter(@"C:\tmp");
        }

        [TestCase(null, Result = null)]
        [TestCase("", Result = null)]
        [TestCase(" ", Result = null)]
        [TestCase(@"C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\Rule Sets\XXX.ruleset", Result = "Bundled;XXX.ruleset")]
        [TestCase(@"C:\tmp\XXX.ruleset", Result = "Custom;XXX.ruleset")]
        [TestCase(@"C:\tmp2\XXX.ruleset", ExpectedException = typeof(InvalidOperationException))]
        public string CovertShouldReturnCorrectValue(string value)
        {
            return testee.Convert(value);
        }

        [TestCase(null, Result = null)]
        [TestCase("", Result = null)]
        [TestCase(" ", Result = null)]
        [TestCase("abc", Result = null)]
        [TestCase("Bundled;XXX.ruleset", Result = @"C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\Rule Sets\XXX.ruleset")]
        [TestCase("Custom;XXX.ruleset", Result = @"C:\tmp\XXX.ruleset")]
        [TestCase("XXX;XXX.ruleset", ExpectedException = typeof(InvalidOperationException))]
        public string ReverseShouldReturnCorrectValuel(string value)
        {
            return testee.Reverse(value);
        }
    }
}
